-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HHH-13788 Schema update try to recreate existing tables #3151
Conversation
} | ||
|
||
@After | ||
public void tearsDown() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"tears" Down ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a typo
.execute( EnumSet.of( TargetType.DATABASE, TargetType.SCRIPT ), metadata ); | ||
|
||
final String fileContent = new String( Files.readAllBytes( output.toPath() ) ); | ||
assertThat( "The update output file should be empty", fileContent, is( "" ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this test. Why does it test that a schema update script is empty ?
Shouldn't we rather test that the schema update is correctly applied?
BTW I tried to revert the fix, and the test will still pass - so there's something probably not working as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we rather test that the schema update is correctly?
depends what you want to test, the issue is the that the update tries to recreate existing tables so we have to check that the update script is empty.
I'll change the name of the test method and the code to express better the aim of the test
I tried to revert the fix, and the test will still pass
You have to try it with MySql
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we specify mysql dialect for the testing, then?
.setFormat( false ) | ||
.execute( EnumSet.of( TargetType.DATABASE, TargetType.SCRIPT ), metadata ); | ||
|
||
final String fileContent = new String( Files.readAllBytes( output.toPath() ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should you use getAbsolutePath
here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAbsolutePath()
returns a String
while Files.readAllBytes
requires a Path
public class SchemaUpdateTestWithUseJdbcMetadataDeaultsTest { | ||
|
||
@Parameterized.Parameters | ||
public static Collection<String> parameters() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, it seems you can use String[]
directly without the wrapping of Arrays.asList
. See https://github.com/junit-team/junit4/wiki/Parameterized-tests#tests-with-single-parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank @NathanQingyangXu I applied your suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be me who say thank you. I borrowed the testing methodology in this PR and applied it in my PR: #3144. During the process, I found we can use array directly. Glad I can help.
@Sanne thanks for the review, I pushed a commit with some changes to the test and any further suggestion to improve it is more than welcome. |
hi @dreab8 , I'm back to trying this out and still have some issues. When I run:
The two new tests fail: |
Hi @Sanne, I checked and it seems the changes fix the issue for MySql but not for PostgreSQL. I'm investigating. Thanks for testing with PostgreSQL. |
Hey. I'm having a look at a few long-standing Quarkus bugs, and it seems this PR was supposed to fix quarkusio/quarkus#5883 . @dreab8 did you find out what was the issue with PostgreSQL in the end? Do you think we could adapt the fix? |
AFAIR this relates to the fact that we didn't have the right metadata - could possibly be solved now since we actually load it? Not sure if the timing is right in relation with schema gen. But yes even if this is still not fixed, it might be easier to solve now. |
the SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseTest set By the way https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/spi/IdentifierHelperBuilder.java#L41 seem wrong to me |
455fb0c
to
226766b
Compare
https://hibernate.atlassian.net/browse/HHH-13788
It should fix quarkusio/quarkus#5883